package com.example.demo.account.entity;

import com.example.demo.information.entity.School;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author littlecar
 * @date 2020/3/16 11:08
 */
@Entity
@Table(name = "user_role")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SysUserRole implements Serializable,Comparable<SysUserRole> {
    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;
    /*@ManyToOne(fetch=FetchType.LAZY,targetEntity = SysUser.class)*/
    @Column
    private Long user_id;
    /*@ManyToOne(fetch=FetchType.LAZY,targetEntity = SysRole.class)*/
    @Column(nullable = false)
    private Long role_id;
    /*@ManyToOne(fetch=FetchType.LAZY,targetEntity = School.class)*/
    @Column
    private Long school_id;

    @Override
    public int compareTo(SysUserRole o2) {
        if(this.getRole_id().intValue()==o2.getRole_id().intValue()){
            return 1;
        }
        return this.getRole_id().intValue() - o2.getRole_id().intValue();
    }
}
